Update README.md
[BattleCats.git] / Assets / Scripts / UI Scripts / LevelSelection.cs
blob98ba657ad976242cbd3151e2eefcb15aea7152b4
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5 using UnityEngine.SceneManagement;
6 using UnityEngine.EventSystems;
8 public class LevelSelection : MonoBehaviour {
10 public int selectedLevel;
11 [SerializeField] GameObject m_ConfirmationPanel;
12 [SerializeField] GameObject m_CancelButton;
13 [SerializeField] GameObject SelectionPanel;
14 [SerializeField] GameObject Level0Button;
15 private GameObject[] menuManagers;
16 private MenuManager menuManagerScript;
19 private void Start()
21 m_ConfirmationPanel.SetActive(false);
22 menuManagers = GameObject.FindGameObjectsWithTag ("MenuManager");
25 public void SelectLevel0()
27 selectedLevel = 0;
28 SelectionPanel.SetActive(false);
29 m_ConfirmationPanel.SetActive(true);
30 EventSystem.current.SetSelectedGameObject(m_CancelButton,null);
33 public void SelectLevel1()
35 selectedLevel = 1;
36 SelectionPanel.SetActive(false);
37 m_ConfirmationPanel.SetActive(true);
38 EventSystem.current.SetSelectedGameObject(m_CancelButton,null);
42 public void SelectLevel2()
44 selectedLevel = 2;
45 SelectionPanel.SetActive(false);
46 m_ConfirmationPanel.SetActive(true);
47 EventSystem.current.SetSelectedGameObject(m_CancelButton, null);
53 public void SelectLevelBoss()
55 selectedLevel = 3;
56 SelectionPanel.SetActive(false);
57 m_ConfirmationPanel.SetActive(true);
58 EventSystem.current.SetSelectedGameObject(m_CancelButton,null);
62 public void GoToSelectedLevel()
64 switch (selectedLevel)
66 case 0:
67 DestroyMenuMusic ();
68 SceneManager.LoadScene("Level0");
69 break;
70 case 1:
71 DestroyMenuMusic ();
72 SceneManager.LoadScene("Level1");
73 break;
74 case 2:
75 DestroyMenuMusic ();
76 SceneManager.LoadScene("Level2a");
77 break;
78 case 3:
79 DestroyMenuMusic ();
80 SceneManager.LoadScene("Level3");
81 break;
85 public void GoBackToSelection()
87 m_ConfirmationPanel.SetActive(false);
88 SelectionPanel.SetActive(true);
89 EventSystem.current.SetSelectedGameObject(Level0Button,null);
92 public void GobackToCharacterSelection()
94 SceneManager.LoadScene("CharacterSelection");
97 public void DestroyMenuMusic()
99 foreach (GameObject manager in menuManagers)
101 menuManagerScript = manager.GetComponent<MenuManager> ();
102 if (menuManagerScript.IsMenuMusicPlaying ())
104 menuManagerScript.StopMenuMusic ();